<template>
    <Modal
            v-model="showGenconfig"
            title="生成器配置"
            @on-ok="save"
            @on-cancel="close"
    >
        <i-form ref="formFilter" label-position="right" :label-width="100">
            <my-component></my-component>
            <form-item label="作者名称：">
                <i-input v-model="genconfigDto.author" placeholder="名称"/>
            </form-item>
            <form-item label="去除表前缀：">
                <i-input v-model="genconfigDto.prefix" placeholder="默认不去除表前缀"/>
            </form-item>
            <!--<form-item label="模块名称：">
                <i-input v-model="genconfigDto.moduleName" placeholder="模块名称"/>
            </form-item>-->
            <form-item label="至于包下：">
                <i-input v-model="genconfigDto.pack" placeholder="后端java代码放的包名"/>
            </form-item>
            <form-item label="前端路径：">
                <i-input v-model="genconfigDto.path" placeholder="前端路径"/>
            </form-item>
            <form-item label="API路径：">
                <i-input v-model="genconfigDto.apiPath" placeholder="API路径"/>
            </form-item>
            <form-item label="是否覆盖：">
                <i-switch v-model="genconfigDto.cover" size="large">
                    <span slot="open">是</span>
                    <span slot="close">否</span>
                </i-switch>
            </form-item>
        </i-form>
    </Modal>
</template>

<script>
    module.exports = {
        props:["showGenconfig"],
        data() {
            return {
                showGenconfig:true,
                genconfigDto:{
                    id:undefined,
                    pack:undefined,
                    moduleName:undefined,
                    path:undefined,
                    apiPath:undefined,
                    author: undefined,
                    prefix: undefined,
                    cover: false,
                }
            }
        },
        mounted() {
            console.info("genconfig vue",this.genconfigDto,this.showGenconfig)
            this.load();
        },
        methods:{
            load() {
                let _this = this;
                _this.loading=true;
                iget('/admin/genconfig',
                    _this.params,
                    successRes => {
                        _this.genconfigDto=successRes
                    },failureRes => {
                        console.info("加载数据异常",failureRes)
                    }
                )
            },
            close(){
                this.showGenconfig=false;
                this.$emit("close",this.showGenconfig);
            },
            save() {
                let _this = this;
                _this.loading=true;
                iput('/admin/genconfig',
                    _this.genconfigDto,
                    successRes => {
                        this.$Notice.success({
                            title: '保存成功'
                        });
                        _this.showGenconfig=false;
                        this.$emit("close",this.showGenconfig);
                    },failureRes => {
                        console.info("加载数据异常asdfg",failureRes)
                    }
                )
            },
        }
    }
</script>
